﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;

namespace Data
{
    public class Playlist
    {
        #region Объектная модель
        static protected readonly Dictionary<Guid, Playlist> _allPlaylists = new Dictionary<Guid, Playlist>();
        static public Dictionary<Guid, Playlist> AllPlaylists { get { return _allPlaylists; } }

        protected Guid _id { get; private set; }
        public Guid ID
        {
            get { return _id; }
        }

        static public Playlist GetById(Guid id)
        {
            return _allPlaylists[id];
        }
        #endregion

        static private readonly String _tableName = "[playlists]";
        static public String TableName
        {
            get { return _tableName; }
        }

        public Playlist(SqlDataReader reader)
        {
            reader.Read();
            _id = (Guid)reader["id"];
            _id_user = (string)reader["id_user"];

            reader.Close();

            _allPlaylists.Add(_id, this);
        }

        private String _id_user;
        public User User
        {
            get
            {
                return User.GetByName(_id_user);
            }
        }

    }
}
